<ui:component xmlns="http://www.w3.org/1999/xhtml"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:a4j="http://richfaces.org/a4j"
              xmlns:rich="http://richfaces.org/rich"
              xmlns:s="http://jboss.com/products/seam/taglib">
    
    <a4j:form>
        <s:decorate id="customerName" template="/templates/form-field.xhtml">
            <ui:define name="label">Customer Name</ui:define>
            
            <rich:comboBox value="#{value.instance.customer}"
                           defaultLabel="Enter a customer"
                           required="true">
                <s:selectItems value="#{customerNames}" var="customerName"/>
                <a4j:support reRender="customerName" event="onblur"/>
            </rich:comboBox>
        </s:decorate>
        
        <s:decorate id="claimReturned"
                    template="/templates/form-field.xhtml"
                    rendered="#{claimHome.managed}">
            <ui:define name="label">Entered Date/Time</ui:define>
            
            <rich:calendar value="#{value.instance.returned}" required="true"
                           enableManualInput="true" reRender="claimReturned" mode="client"
                           datePattern="M/dd/yy hh:mm a" showApplyButton="true">
               <a4j:support reRender="claimReturned" event="onblur"/>
           </rich:calendar>
        </s:decorate>
        
        <s:decorate id="claimLocation" template="/templates/form-field.xhtml">
            <ui:define name="label">Location Parked</ui:define>
            
            <rich:comboBox value="#{value.instance.location}"
                           defaultLabel="Enter a location"
                           suggestionValues="#{locations}"
                           required="true">
               <a4j:support reRender="claimLocation" event="onblur"/>
           </rich:comboBox>
        </s:decorate>
        
        <s:decorate id="claimParkedBy" template="/templates/form-field.xhtml">
            <ui:define name="label">Parked By</ui:define>
            
            <rich:comboBox value="#{value.instance.parkedBy}"
                           defaultLabel="Enter an employee"
                           suggestionValues="#{employees}"
                           required="true">
               <a4j:support reRender="claimParkedBy" event="onblur"/>
           </rich:comboBox>
        </s:decorate>
        
        <s:decorate id="carLP" template="/templates/form-field.xhtml">
            <ui:define name="label">License Plate</ui:define>
            
            <rich:comboBox value="#{value.instance.car}"
                           defaultLabel="Enter an license plate"
                           suggestionValues="#{cars}"
                           required="true">
               <a4j:support reRender="carLP" event="onblur"/>
           </rich:comboBox>
        </s:decorate>
        
        <s:decorate id="carMake" template="/templates/form-field.xhtml">
            <ui:define name="label">Make</ui:define>
            
            <rich:comboBox id="makeBox"
                           value="#{value.instance.car.make}"
                           defaultLabel="Enter a make"
                           required="true"
                           suggestionValues="#{makes}">
               <a4j:support reRender="carMake" event="onblur"/>
           </rich:comboBox>
        </s:decorate>
        
        <s:decorate id="carColor" template="/templates/form-field.xhtml">
            <ui:define name="label">Color</ui:define>
            
            <rich:comboBox value="#{value.instance.car.color}"
                           directInputSuggestions="true"
                           defaultLabel="Enter a color"
                           required="true">
                <s:enumItem enumValue="Black" label="Black"/>
                <s:enumItem enumValue="Blue" label="Blue"/>
                <s:enumItem enumValue="Green" label="Green"/>
                <s:enumItem enumValue="Gold" label="Gold"/>
                <s:enumItem enumValue="Gray" label="Gray"/>
                <s:enumItem enumValue="Red" label="Red"/>
                <s:enumItem enumValue="Yellow" label="Yellow"/>
                <s:enumItem enumValue="White" label="White"/>
                <a4j:support reRender="carColor" event="onblur"/>
            </rich:comboBox>
        </s:decorate>
        
        <s:decorate id="claimCarWash" template="/templates/form-field.xhtml">
            <ui:define name="label">Car Wash</ui:define>
            
            <h:selectOneRadio  value="#{value.instance.carWash}" required="true">
                <f:selectItem itemValue="true" itemLabel="Yes"/>
                <f:selectItem itemValue="false" itemLabel="No"/>
            </h:selectOneRadio>
        </s:decorate>
        
        <s:decorate id="claimComments" template="/templates/form-field.xhtml">
            <ui:define name="label">Comments</ui:define>
            
            <h:inputTextarea value="#{value.instance.comments}">
                <a4j:support event="onblur" reRender="claimComments" bypassUpdates="true"/>
            </h:inputTextarea>
        </s:decorate>
        
        <s:decorate id="claimDamageReport" template="/templates/form-field.xhtml">
            <ui:define name="label">Damage Report</ui:define>
            
            <h:inputTextarea value="#{value.instance.damageReport}">
                <a4j:support event="onblur" reRender="claimDamageReport" bypassUpdates="true"/>
            </h:inputTextarea>
        </s:decorate>
        
        <h:panelGroup rendered="#{!claimHome.managed}">
            <h:commandButton value="Create" action="#{value.persist}"/>
        </h:panelGroup>
        
        <h:panelGroup rendered="#{claimHome.managed}">
            <h:commandButton value="Save" action="#{value.update}"/>
            &#160;
            <h:commandButton value="Delete" action="#{value.remove}"/>
        </h:panelGroup>
        &#160;
        <h:commandButton value="Cancel" action="#{value.create}" immediate="true"/>
    </a4j:form>
    
</ui:component>
